<?php
/*
 * 行情显示页面
 * @author  Mark
 * @package ixdcw
 * @file    show.inc.php
 * @time    12-12-13 下午2:03
 */
defined('IN_IXDCW') or exit('Access Denied');
require DT_CORE.'/'.MODULE_NAME.'/common.inc.php';
// itemid 没有传参
$itemid or dheader($MOD['linkurl']);
$item = $db->getOne("SELECT * FROM {$table} WHERE itemid=$itemid");
// item正常
if($item && $item['status'] > 2) {
	// 是外链
	if($item['islink']) dheader($item['linkurl']);

	// 获取变量
	extract($item);
} else {
	$head_title = lang('message->item_not_exists');
	@header("HTTP/1.1 404 Not Found");
	exit(include template('show-notfound', 'message'));
}
// 分类的ID属性
$CAT = get_cat($catid);

$t = $db->getOne("SELECT content FROM {$table_data} WHERE itemid=$itemid");
$content = $t['content'];

// 时间格式
$adddate = timetodate($addtime, 3);
$editdate = timetodate($edittime, 3);

// 来源地址
if($fromurl) $fromurl = fix_link($fromurl);
// 链接地址
$linkurl = linkurl($linkurl, 1);
$titles = array();
// 分页标题
if($subtitle) {
	$titles = explode("\n", $subtitle);
	$titles = array_map('trim', $titles);
}
$subtitle = isset($titles[$page-1]) ? $titles[$page-1] : '';
// 关键词
$keytags = $tag ? explode(' ', $tag) : array();
$update = '';

// 不需要花费费用.
$user_status = 3;

$pages = '';
// 子标题处理
$subtitles = count($titles);
if(strpos($content, '[pagebreak]') !== false) {
	$content = explode('[pagebreak]', $content);
	$total = count($content);
	$pages = showpages($item, $total, $page);
	$content = $content[$page-1];
	if($total < $subtitles) $subtitles = $total;
}
// 内容关联链接
if($MOD['keylink']) $content = keylink($content, $moduleid);
include DT_INC.'/update.inc.php';
// seo 文件
$seo_file = 'show';
include DT_INC.'/seo.inc.php';
if($subtitle) $seo_title = $subtitle.$seo_delimiter.$seo_title;
// 模版, 检查类和模块
$template = 'show';
if($MOD['template_show']) $template = $MOD['template_show'];
if($CAT['show_template']) $template = $CAT['show_template'];
if($item['template']) $template = $item['template'];
include template($template, MODULE_NAME);